
var minDepth = function(root) {//*
    const queue=[root];let depth=0
    if(!root)return depth
    while(queue.length){
        let len=queue.length;
        depth++
        for(let i=1;i<=len;i++){
            let node=queue.shift()
            if(!node.left&&!node.right)return depth
            node.left&&queue.push(node.left)
            node.right&&queue.push(node.right)
        }
    }
    };